<%@page import="java.awt.print.Printable"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>

<meta HTTP-EQUIV="pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<meta HTTP-EQUIV="expires" CONTENT="0">
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
%>
<title>_${customer.customerName}_创建作业任务</title>

<script type="text/javascript">
  $(function() {
	var size='${orderList.size()}';
	if(size==0){
	   $("#btn_pre").attr("disabled", true);
	   $("#btn_pre").attr("class", "btn");
	   $("#btn_pre").val("所有订单已生成任务");
	   $("#btn_pre").attr("onclick",""); 
	}
	
  });
  
  
    //指派任务
	function task(taskId){
	
	  var btn_id="#btn_"+taskId;
	  var picker_id="#picker_"+taskId;
	  var status_id="#status_"+taskId;
	  
	  var jobuuid=$(picker_id).val();
	
	  if(jobuuid==''){
	    alert("请选择执行人");
	    $(picker_id).focus();
	    return;
	  }
	  
	  $.ajax({
			type : 'post',
			url : '${ctx}/workTask/ajaxCommandTask',
			data : {
				jobuuid : jobuuid,
				taskId : taskId
			},
			dataType : 'json',
			success : function(data) {
			    var msg=data.msg;
				if (msg == "success") {
					 alert("任务指派成功！");
					 $(btn_id).attr("disabled", true);
	                 $(btn_id).attr("class", "btn");
	                 $(btn_id).val("已指派");
	                 $(picker_id).attr("disabled", true);
	                 $(status_id).html("已指派任务");
				}else if(msg=="token"){
				    alert("此任务已被分配。");
				    location.reload();
				}else {
					alert("网络繁忙，请稍后重试...");
				}
			},
			error : function() {
				alert("网络繁忙，请稍后重试...");
			}
		});
	}
</script>
</head>

<body>

<section class="content">
<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">创建作业任务</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
				
	<table class="table table-striped table-bordered table-condensed" style="margin-top: 0px;">
<!-- 		<thead> -->
<!-- 			<th style="vertical-align: middle; color: white; " colspan="1" bgcolor="#8EB4CB">创建作业任务</th> -->
<!-- 		</thead> -->
		<tr>
		   <td>
		     
		     <form class="form-search" id="queryForm" method="post" action="${ctx}/workTask/v2_preWorkTask" style="margin-top: 10px;">
			 	
			 	
			 	<div class="col-sm-3">
					<div class="input-group col-sm-12">
						<span class="input-group-text">拣货策略:</span> 
						<select class="form-control"  id="tactics" name="tactics">
							<c:if test="${batch.tacticsType eq 'timefirst' or  batch.tacticsType eq 'skufirst' or  batch.tacticsType eq 'onesku' or  batch.tacticsType eq 'prepkg'}">
								<option value="path" >路径优化策略</option>
						        <option value="SKU" >SKU集中策略</option>
						        <option value="onesku" >单品合拣策略</option>
						        <option value="prepkg" >预包装策略</option>
					        </c:if>
							<c:if test="${batch.tacticsType eq 'promotion'}">
						        <option value="promotion" selected="selected" >大促策略</option>
							</c:if>
							<c:if test="${batch.tacticsType eq 'comb'}">
						        <option value="comb" selected="selected" >组合策略</option>
							</c:if>
							
	                        <!--  <option value="wholeBox" >整箱分拣策略</option> -->
					        <!--  <option value="" >组合策略</option> -->
						</select> 
					</div>
				</div>
				
				<c:if test="${batch.tacticsType eq 'timefirst' or  batch.tacticsType eq 'skufirst' or  batch.tacticsType eq 'onesku' or  batch.tacticsType eq 'prepkg'}">
			 	 <div class="col-sm-3">
					<div class="input-group col-sm-12">
						<span class="input-group-text">任务容量: </span> 
						<select class="form-control" id="taskcount" name="taskcount">
						        <option value="15">15</option>
						        <option value="20">20</option>
						        <option value="25">25</option>  
						        <option value="30">30</option>  
						        <option value="50">50</option> 
						        <option value="60">60</option>
						        <option value="90">90</option> 
						        <option value="100">100</option>
						        <option value="200">200</option>
						        <option value="500">500</option>
						 </select>
					</div>
				</div>
				</c:if>
				
				
				 <input type="hidden" name="batchCode" value="${batch.batchCode}">
				 <input type="hidden" name="pickType" value="${batch.pickType}">
				
				<input type="submit" value="预览作业任务" class="btn btn-primary" id="btn_pre">
				
		    </form>
		    
		   </td>
		</tr>
	</table>
	</div>
	</div>
	</div>
	</div>
	
	
	
	<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">已创建任务</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
				
				
	
	<!-- 已创建任务 -->
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
<!-- 		<thead> -->
<!-- 			<th style="vertical-align: middle; color: white; " colspan="12" bgcolor="#8EB4CB">已创建任务</th> -->
<!-- 		</thead> -->
		<thead><tr>
			    <th>序号</th>
			    <th style="width: 100px;">批次编号</th>
			    <th style="width: 100px;">任务编号</th>
			    <th>订单数量</th>
			    <th>创建人</th>
			    <th>任务状态</th>
<!-- 			    <th>执行人</th> -->
<!-- 			    <th>操作</th> -->
			</tr></thead>
		<tbody>
		<c:if test="${empty taskList or taskList.size() eq 0}">
	       <tr><td colspan="19" height="50" style="vertical-align:middle; text-align: center;color: gray;font-size: 20px;">无数据</td></tr>
	    </c:if>
		<c:forEach items="${taskList}" var="t" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			   <td>${t.batchCode}</td>
			   <td>${t.taskCode}</td>
			   <td>${t.orderQty}</td>
			   <td>${t.creater.realname}</td>
			   <td id="status_${t.id}">
			     <!-- 任务状态( 1.创建任务 2.已分配拣货任务 3.已拣货 4. 已分配灯光拣选任务 5.已经灯光拣选 6.已分配包装任务 7.已包装 8.已分配发货任务 9.已发货 10.灯光拣选中.. 11.推车拣选中.. 12.拣货中...) -->
			     <c:if test="${t.status eq '1'}"><font color=blue>创建任务</font></c:if>
			     <c:if test="${t.status eq '2'}"><font color=blue>已分配拣货任务</font></c:if>
			     <c:if test="${t.status eq '3'}"><font color=blue>已拣货</font></c:if>
			     <c:if test="${t.status eq '4'}"><font color=blue>已分配灯光拣选任务</font></c:if>
			     <c:if test="${t.status eq '5'}"><font color=blue>已经灯光拣选</font></c:if>
			     <c:if test="${t.status eq '6'}"><font color=blue>已分配包装任务</font></c:if>
			     <c:if test="${t.status eq '7'}"><font color=blue>已包装</font></c:if>
			     <c:if test="${t.status eq '8'}"><font color=blue>已分配发货任务</font></c:if>
			     <c:if test="${t.status eq '9'}"><font color=blue>已发货</font></c:if>
			     <c:if test="${t.status eq '10'}"><font color=blue>灯光拣选中..</font></c:if>
			     <c:if test="${t.status eq '11'}"><font color=blue>推车拣选中..</font></c:if>
			     <c:if test="${t.status eq '12'}"><font color=blue>拣货中..</font></c:if>
			   </td>
		</c:forEach>
		</tbody>
	</table>
	</div>
	</div>
	</div>
	</div>
	
	
	<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">未处理订单</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
	
	
    <!-- 未处理订单 -->
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
<!-- 	<thead> -->
<!-- 		<th style="vertical-align: middle; color: white; " colspan="12" bgcolor="#8EB4CB">未处理订单</th> -->
<!-- 	</thead> -->
	<thead><tr>
		    <th>序号</th>
		    <th>订单号</th>
		    <th>订单类型</th>
		    <th>订单状态</th>
		</tr></thead>
	<tbody>
	<c:if test="${empty orderList or orderList.size() eq 0}">
	   <tr><td colspan="19" height="50" style="vertical-align:middle; text-align: center;color: gray;font-size: 20px;">无数据</td></tr>
	</c:if>
	<c:forEach items="${orderList}" var="o" varStatus="i">
		<tr>
		   <td>${i.count}</td>
		   <td>${o.order.ordeno}</td>
		   <td>
		     <c:if test="${o.order.orderType eq 'single'}">单件</c:if>
		     <c:if test="${o.order.orderType eq 'multiple'}">多件</c:if>
		   </td>
		   <td>
		     <c:if test="${o.status eq '1'}"><font color='red'>待处理</font></c:if>
		     <c:if test="${o.status eq '2'}"><font color='blue'>已处理</font></c:if>
		     <c:if test="${o.status eq '3'}"><font color='blue'>待处理</font></c:if>
		   </td>
	</c:forEach>
	</tbody>
</table>
</div>
</div>
</div>
</div>

</section>
</body>
</html>
